<?php

class GraphicDAO extends DataLayer {
 		
	/**
	* @desc Construtor da Classe
 	*/
	function __construct($lk){
		$this->lk			= $lk;
	}

	public function getHoursSprint($idSprint){
		$this->result = NULL;

		$this->sql ="	SELECT
							SUM(t.custo_estimado) hours, DATEDIFF(s.data_final,s.data_inicial) days, s.data_inicial dateBegin, s.data_final dateEnd, s.ordem `order`
						FROM
							sprints s													
						INNER JOIN
							tarefas t on t.id_sprint = s.id_sprint
						WHERE 
							s.id_sprint = ".$idSprint;

		$this->result = parent::select($this->sql);
		return $this->result;
	}

	public function getHoursWorket($idSprint){
		$this->result = NULL;

		 $this->sql ="	SELECT
							SUM(quantidade_horas) hours, ta.data_andamento dateGoing
						FROM							
							sprints s
						INNER JOIN
							tarefas t on t.id_sprint = s.id_sprint
						INNER JOIN
							tarefas_andamentos ta on ta.id_tarefa = t.id_tarefa
						WHERE 
							s.id_sprint = ".$idSprint."							
						GROUP BY
							ta.data_andamento
						ORDER BY
							ta.data_andamento";

		$this->result = parent::select($this->sql);
		return $this->result;
	}
}

/*
INSERT INTO tarefas_andamentos (id_tarefa,quantidade_horas, data_andamento, data )
SELECT `id_tarefa`,(custo_estimado+10) custo_estimado, data_limite, now() FROM tarefas WHERE id_sprint = 2
*/
?>